//定义组件
define(function (require, exports, module) {

    var _ = require("lib/lodash.js");


    var api = {
        //后期直接变成ajax
        getArtList: function (option) {
            //$.ajax(option);
            console.log(option);
            $.ajax({
                url: ARTICLE_URLS.ARTICLE_LIST,//这里是后台接口需要换掉
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(option.params),
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
            // var filtedList = _.filter(data.ArtList, option.params)
            // return option.callBack(filtedList);
        },
        getArtSimpleMod: function (option) {
            //$.ajax(option);
            return data.ArtSimpleMod;
        },
        queryCategoryList: function (option) {
            $.ajax({
                url: CATEGORY_URLS.CATEGORY_PID + "/" + option.params.pId,//这里是后台接口需要换掉
                type: 'GET',
                contentType: 'application/json',
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });

            //var filtedList = _.filter(data.CategoryList, option.params);
            //return option.callBack(filtedList);
        },
        queryCategoryTreeList: function (option) {
            return option.callBack(data.CategoryaTreeList);
        },
        getChapterList: function (option) {
            $.ajax({
                url: CHAPTER_LIST + "/" + option.params.bookId + "/" + option.params.pageNo + "/" + option.params.pageSize,//这里是后台接口需要换掉
                type: 'GET',
                contentType: 'application/json',
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
        },
        changeArtByBookId: function (option) {
            $.ajax({
                url: ARTICLE_URLS.ARTICLE_DELETE + "/" + option.params.bookId + "/" + option.params.dataFlag,//这里是后台接口需要换掉
                type: 'GET',
                contentType: 'application/json',
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
        },
        getCategorySunList: function (option) {
            console.log(option);
            $.ajax({
                url: CATEGORY_URLS.CATEGORY_LIST,//这里是后台接口需要换掉
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(option.params),
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
        },
        getJobList: function (option) {
            console.log(option);
            $.ajax({
                url: JOB_URLS.JOB_LIST + "/" + option.params.pageNo + "/" + option.params.pageSize,//这里是后台接口需要换掉
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(option.params),
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
        },
        handleStartJob: function (option) {
            $.ajax({
                url: JOB_URLS.JOB_START,//这里是后台接口需要换掉
                type: 'GET',
                contentType: 'application/json',
                dataType: "json",
                cache: false,
                processData: false,
                success: (res) => {
                    return option.callBack(res);
                },
                error: function (err) {
                    toastr.error("网络错误");
                }
            });
        }
    };

    var data = {
        ArtList: [{
            id: '1',
            title: 'OBA，这个星球属于我！',
            summary: '我心中的演员表（暂定，因为心里总是轮番让这几个人试戏，所以总是有变动，但是蓝冥睿的位置却是一直没动过滴呵呵呵嘎嘎嘎',
            parentCategoryId: 1,
            parentCategoryName: '女生频道',
            categoryId: 6,
            categoryName: '幻想言情',
            dataFlag: 1
        },
        {
            id: '2',
            title: '宁负苍天',
            summary: '我心中的演员表（暂定，因为心里总是轮番让这几个人试戏，所以总是有变动，但是蓝冥睿的位置却是一直没动过滴呵呵呵嘎嘎嘎',
            parentCategoryId: 1,
            parentCategoryName: '女生频道',
            categoryId: 7,
            categoryName: '现代言情',
            dataFlag: 1
        }, {
            id: '3',
            title: '傲女天下',
            summary: '我心中的演员表（暂定，因为心里总是轮番让这几个人试戏，所以总是有变动，但是蓝冥睿的位置却是一直没动过滴呵呵呵嘎嘎嘎',
            parentCategoryId: 1,
            parentCategoryName: '男生频道',
            categoryId: 14,
            categoryName: '仙侠武侠',
            dataFlag: 0
        }],
        ArtSimpleMod: {
            id: '3',
            title: '傲女天下',
            summary: '我心中的演员表（暂定，因为心里总是轮番让这几个人试戏，所以总是有变动，但是蓝冥睿的位置却是一直没动过滴呵呵呵嘎嘎嘎',
            categoryId: 3,
            categoryName: '立方停车',
            dataFlag: 1
        },
        CategoryList: [{
            id: 1,
            name: '女生频道',
            pId: 0
        }, {
            id: 2,
            name: '男生频道',
            pId: 0
        }, {
            id: 3,
            name: '精口文学',
            pId: 0
        },
        {
            id: 4,
            name: '影视出版',
            pId: 0
        },
        {
            id: 5,
            name: '二次元',
            pId: 0
        }, {
            id: 6,
            name: '幻想言情',
            pId: 1
        }, {
            id: 7,
            name: '现代言情',
            pId: 1
        }],
        CategoryaTreeList: [{
            id: 1,
            label: '女生频道',
            pId: 0,
            children: [{
                id: 6,
                label: '幻想言情',
                pId: 1
            }, {
                id: 7,
                label: '现代言情',
                pId: 1
            }]
        }, {
            id: 2,
            label: '男生频道',
            pId: 0
        }, {
            id: 3,
            label: '精口文学',
            pId: 0
        },
        {
            id: 4,
            label: '影视出版',
            pId: 0
        },
        {
            id: 5,
            label: '二次元',
            pId: 0
        }]

    };

    module.exports = api;

});
